package com.soup.lab.executor.pool;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.function.Predicate;

public class TaggableFutureTask<V> extends FutureTask<V> implements Taggable {

    private Taggable tagHolder;

    public TaggableFutureTask(Callable<V> callable) {
        super(callable);
        this.tagHolder = new TagHolder();
    }

    public TaggableFutureTask(Runnable runnable, V result) {
        super(runnable, result);
        this.tagHolder = new TagHolder();
    }

    @Override
    public void tag(Tag tag) {
        tagHolder.tag(tag);
    }

    @Override
    public List<Tag> getTags() {
        return tagHolder.getTags();
    }

    @Override
    public List<Tag> removeIf(Predicate<Tag> filter) {
        return tagHolder.removeIf(filter);
    }

    @Override
    public void clear() {
        tagHolder.clear();
    }
}
